import axios from 'axios'
import commonUrl from '../common/js/commonUrl.js'
import { loadVillageId } from '../common/js/cache.js'

// 论坛数据列表
export function getMessage () {
  const url = `${commonUrl.apihost}index.php/home/forum/index/?areas_id=${loadVillageId()}`
  return axios({
    method: 'GET',
    url: url
  }).then((res) => {
    return Promise.resolve(res.data)
  }).catch((err) => {
    return Promise.reject(err)
  })
}

// 论坛的详情
export function getReply (id) {
  const url = `${commonUrl.apihost}index.php/home/forum/getComments/?id=${id}`
  return axios({
    method: 'GET',
    url: url
  }).then((res) => {
    return Promise.resolve(res.data)
  }).catch((err) => {
    return Promise.reject(err)
  })
}

